FROM golang:alpine as builder

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

RUN apk update && apk add tzdata

WORKDIR /go/release

ENV GOPROXY https://goproxy.cn/

COPY go.mod ./go.mod

RUN go mod tidy

COPY . .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -a -installsuffix cgo -o main .

FROM alpine:latest

COPY --from=builder /go/release/main /app/main

COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

WORKDIR /app

EXPOSE 9002

ENTRYPOINT ["./main"]